package io.babystar.modules.app.controller;

import io.babystar.common.utils.PageUtils;
import io.babystar.common.utils.R;
import io.babystar.modules.business.entity.StudentCourseDateEntity;
import io.babystar.modules.business.service.CourseDateService;
import io.babystar.modules.business.service.StudentCourseDateService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;


/**
 * 
 *
 * @author jeson
 * @email 574197743@qq.com
 * @date 2021-03-23 20:03:34
 */
@RestController
@Api("已约页面接口")
@RequestMapping("app/haveappointment")
public class HaveAppointmentRest {
    @Autowired
    private CourseDateService courseDateService;
    @Autowired
    private StudentCourseDateService studentCourseDateService;

    /**
     * 学生已预约/取消列表
     */
    //@Login
    @ApiOperation("学生已预约/签到/取消列表")//
    @PostMapping("/studenthasappointment")
    public R studentHasAppointment(@RequestBody Map<String, Object> params){
        //params.put("status", 0);0/1/2
        Integer parentId = (Integer)params.get("parentId");
        if(parentId==null){
            return R.error("请先登陆！");
        }
        PageUtils page = courseDateService.studentHasAppointment(params);

        return R.ok().put("page", page);
    }

    /**
     * 取消预约
     */
    //@Login
    @ApiOperation("取消预约")
    @GetMapping("/cancelappointment")
    public R cancelAppointment(@RequestParam Long id){
        StudentCourseDateEntity studentCourseDateEntity = new StudentCourseDateEntity();
        studentCourseDateEntity.setId(id);
        //studentCourseDateEntity.setStatus(2);
        //studentCourseDateService.updateById(studentCourseDateEntity);
        studentCourseDateService.removeById(id);
        return R.ok();
    }


}
